package com.itheima.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class map {
    public static void main(String[] args) {
        Map<String,String> map=new HashMap<>();
        map.put("2017","张三");
        map.put("2018","李四");
        map.put("2019","王五");
        //method1(map);
        //methodremove(map);
        //methodContain(map);
       // map.clear();
       // System.out.println(map.isEmpty());
//        Set<String> keys = map.keySet();
//        for (String key : keys) {
//            String value = map.get(key);
//            System.out.println(key+"===="+value);
//        }
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"---------"+value);
        }


    }

    private static void methodContain(Map<String, String> map) {
        System.out.println(map.containsKey("2018"));
        System.out.println(map.containsValue("张三"));
        System.out.println(map.containsKey("2020"));
        System.out.println(map.containsValue("anb"));
    }

    private static void methodremove(Map<String, String> map) {
        System.out.println(map.remove("2017"));
        System.out.println(map);
        System.out.println(map.remove("2018", "李四"));
        System.out.println(map);
    }

    private static void method1(Map<String, String> map) {
        map.put("2017","赵柳");
        System.out.println(map);
    }
}
